import requests from "@/utils/request/index";

export function getCaptcha(extra?: Requests.ExtraConfig) {
  return requests<Api.GetCaptchaRes>({
    url: "/blade-auth/captcha",
    method: "get",
    extra,
  });
}

export function loginByPwd(params: Api.LoginByPwdReq, extra?: Requests.ExtraConfig) {
  const { code: code, key: key, ...rest } = params;
  return requests<Api.LoginByPwdRes>({
    url: "/blade-auth/token",
    method: "post",
    headers: { "Captcha-Key": key, "Captcha-Code": code },
    params: rest,
    extra,
  });
}

// export function refreshToken(extra?: Requests.ExtraConfig) {
//   return requests({
//     url: "/user/refesh",
//     method: "post",
//     extra,
//   });
// }

export function getMenus(extra?: Requests.ExtraConfig) {
  return requests<Api.Menus[]>({
    url: "/blade-system/menu/routes",
    method: "get",
    extra,
  });
}
